/*
 * Created by JFormDesigner on Tue Mar 02 16:39:58 CST 2021
 */

package com.company;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author test
 */
public class SwingEvent extends JPanel {
    public SwingEvent() {
        initComponents();
    }

    public static void main(String[] args) {
        // Swing框架，用于生成一个容纳界面的窗口
        JFrame jFrame = new JFrame();
        jFrame.setSize(700,630);
        jFrame.setTitle("LiLi语音合成");
        SwingEvent swingEvent = new SwingEvent();
        jFrame.setContentPane(swingEvent);//加载单击事件
        jFrame.setVisible(true);
        jFrame.setResizable(false);//不能重置大小
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//退出
    }

    private void btnClickMouseClicked(MouseEvent e) {
        // TODO add your code here
        System.out.println("Click Me!");
        JOptionPane.showMessageDialog(null,"触发了单击事件","Click Me!",JOptionPane.INFORMATION_MESSAGE);
        JOptionPane.showMessageDialog(null,"触发了单击事件","Click Me!",JOptionPane.ERROR_MESSAGE);
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - test
        btnClick = new JButton();

        //======== this ========
        setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(
        0,0,0,0), "JF\u006frmDes\u0069gner \u0045valua\u0074ion",javax.swing.border.TitledBorder.CENTER,javax.swing.border.TitledBorder
        .BOTTOM,new java.awt.Font("D\u0069alog",java.awt.Font.BOLD,12),java.awt.Color.
        red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener(){@Override public void propertyChange(java.
        beans.PropertyChangeEvent e){if("\u0062order".equals(e.getPropertyName()))throw new RuntimeException();}});
        setLayout(null);

        //---- btnClick ----
        btnClick.setText("Click Me");
        btnClick.setFont(new Font("\u9ed1\u4f53", Font.PLAIN, 20));
        btnClick.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                btnClickMouseClicked(e);
            }
        });
        add(btnClick);
        btnClick.setBounds(250, 20, 215, 85);

        setPreferredSize(new Dimension(700, 600));
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - test
    private JButton btnClick;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
